package acm.pta4;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class T2 {
    public static void main(String[] args) throws IOException {
        int[] map=new int[1001];
        BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
        int n =Integer.parseInt(in.readLine());
        String[] read=null;
        while (n-- > 0) {
            read=in.readLine().split(" ");
            int m=Integer.parseInt(read[0]);
            for (int i = 1; i <= m; i++) {
                map[Integer.parseInt(read[i])]++;
            }
        }
        int maxIndex=0;
        for (int i = 0; i < map.length; i++) {
            if (map[i]>=map[maxIndex]){
                maxIndex=i;
            }
        }
        System.out.println(maxIndex+" "+ map[maxIndex]);
    }
}
